package com.mongodb.demo;

import org.bson.Document;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;

/**
 * @author zhangbowen
 * @date 2019/5/9
 **/
@WritingConverter
public class CustomWriteGeoJsonConverter implements Converter<CustomGeoJson, Document> {
    @Override
    public Document convert(CustomGeoJson geoJson) {
        Document document = new Document();
        document.put(GeoJsonConstant.TYPE, geoJson.getType());
        document.put(GeoJsonConstant.COORDINATES, geoJson.getCoordinates());
        return document;
    }
}
